home *** CD-ROM | disk | FTP | other *** search
/ Game Programming in C++ - Start to Finish / GameProgrammingS.iso / developer_install / CEGUISDK-0.4.1-VC6-STLport.exe / {app} / Samples / common / src / CLICEGuiRendererSelector.cpp < prev    next >
C/C++ Source or Header  |  2005-03-09  |  3KB  |  95 lines

  1. /************************************************************************
  2.     filename:   CLICEGuiRendererSelector.cpp
  3.     created:    5/3/2005
  4.     author:     Paul D Turner
  5. *************************************************************************/
  6. /*************************************************************************
  7.     Crazy Eddie's GUI System (http://crayzedsgui.sourceforge.net)
  8.     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
  9.  
  10.     This library is free software; you can redistribute it and/or
  11.     modify it under the terms of the GNU Lesser General Public
  12.     License as published by the Free Software Foundation; either
  13.     version 2.1 of the License, or (at your option) any later version.
  14.  
  15.     This library is distributed in the hope that it will be useful,
  16.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18.     Lesser General Public License for more details.
  19.  
  20.     You should have received a copy of the GNU Lesser General Public
  21.     License along with this library; if not, write to the Free Software
  22.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  23. *************************************************************************/
  24. #include "CLICEGuiRendererSelector.h"
  25. #include <iostream>
  26.  
  27. CLICEGuiRendererSelector::CLICEGuiRendererSelector()
  28. {}
  29.  
  30. CLICEGuiRendererSelector::~CLICEGuiRendererSelector()
  31. {}
  32.  
  33. bool CLICEGuiRendererSelector::inkokeDialog()
  34. {
  35.     unsigned int selection;
  36.     unsigned int rendererNumber = 0;
  37.  
  38.     std::cout << "-- CEGUI Sample Application Framework --" << std::endl;
  39.     std::cout << "Please select a renderer:" << std::endl;
  40.  
  41.     // print options for enabled renderers
  42.     if (d_rendererAvailability[OgreGuiRendererType])
  43.     {
  44.         ++rendererNumber;
  45.         std::cout << rendererNumber << ". Ogre3D GUI Renderer." << std::endl;
  46.     }
  47.     if (d_rendererAvailability[OpenGLGuiRendererType])
  48.     {
  49.         ++rendererNumber;
  50.         std::cout << rendererNumber << ". OpenGL GUI Renderer." << std::endl;
  51.     }
  52.     if (d_rendererAvailability[IrrlichtGuiRendererType])
  53.     {
  54.         ++rendererNumber;
  55.         std::cout << rendererNumber << ". Irrlicht GUI Renderer." << std::endl;
  56.     }
  57.  
  58.     // abort if no renderers are available.
  59.     if (rendererNumber == 0)
  60.     {
  61.         std::cout << "Oops!  There are no renderer modules available, check your config!" << std::endl;
  62.         return false;
  63.     }
  64.  
  65.     // get user to pick a valid option.
  66.     std::cin >> selection;
  67.     while (selection > rendererNumber)
  68.     {
  69.         std::cout << "Oops!  That was not a valid selection, please try again..." << std::endl;
  70.         selection = 0;
  71.         std::cin >> selection;
  72.     }
  73.  
  74.     // discover which renderer was actually selected.
  75.     if ((d_rendererAvailability[OgreGuiRendererType]) && (--selection == 0))
  76.     {
  77.         d_lastSelected = OgreGuiRendererType;
  78.     }
  79.     else if ((d_rendererAvailability[OpenGLGuiRendererType]) && (--selection == 0))
  80.     {
  81.         d_lastSelected = OpenGLGuiRendererType;
  82.     }
  83.     else if ((d_rendererAvailability[IrrlichtGuiRendererType]) && (--selection == 0))
  84.     {
  85.         d_lastSelected = IrrlichtGuiRendererType;
  86.     }
  87.     else
  88.     {
  89.         std::cout << "Something went horribly wrong :(" << std::endl;
  90.         return false;
  91.     }
  92.  
  93.     return true;
  94. }
  95.